{!! Html::style(env("APP_URL").'/assets/backend/libs/datepicker/bootstrap-datetimepicker.min.css') !!}
{!! Html::style('assets/backend/libs/webuploader-0.1.5/webuploader.css') !!}

<div class="ibox float-e-margins">

    <div class="ibox-content" style="display: block;">
        <div class="row">

            <div class="panel-body">
                {!! Form::open( [ 'url' => [route('admin.shop.clerk.store',$shop_id)], 'method' => 'POST', 'id' => 'create-clerk-form','class'=>'form-horizontal'] ) !!}

                <div class="form-group">
                    {!! Form::label('avatar', '头像', ['class' => 'col-lg-2 control-label']) !!}
                    <div class="col-lg-10">
                        <div class="pull-left" id="userAvatar">
                            <img src="/assets/backend/admin/img/no_head.png"
                                 style="
                                         margin-right: 23px;
                                         width: 100px;
                                         height: 100px;
                                         border-radius: 50px;">
                            {!! Form::hidden('avatar', null, ['class' => 'form-control']) !!}
                        </div>
                        <div class="clearfix" style="padding-top: 22px;">
                            <div id="filePicker">添加图片</div>
                            <p style="color: #b6b3b3">温馨提示：图片尺寸建议为：250*250, 图片小于4M</p>
                        </div>
                    </div>
                </div><!--form control-->
                <input type="hidden" name="shop_id" value="{{$shop_id}}">

                <div class="form-group">
                    <label class="col-sm-2 control-label">*手机：</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="mobile" placeholder="" required="required"/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">*密码：</label>
                    <div class="col-sm-8">
                        <input type="password" class="form-control" name="password" placeholder=""/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">*确认密码：</label>
                    <div class="col-sm-8">
                        <input type="password" class="form-control" name="password_confirmation" placeholder=""/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">*导购工号：</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="clerk_no" placeholder=""/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">*姓名：</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="name" placeholder=""/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">昵称：</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="nickname" placeholder=""/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">邮箱：</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="email" placeholder=""/>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">*启用：</label>
                    <div class="col-sm-10">
                        <label class="checkbox-inline i-checks"><input name="status" type="radio"
                                                                       value="1" checked>
                            是</label>
                        <label class="checkbox-inline i-checks"><input name="status" type="radio"
                                                                       value="0"> 否</label>
                    </div>
                </div>


                <div class="form-group">
                    <label class="col-sm-2 control-label">*店长：</label>
                    <div class="col-sm-10">
                        <label class="checkbox-inline i-checks"><input name="is_clerk_owner" type="radio"
                                                                       {{$is_has_clerk_owner?'disabled':''}}

                                                                       value="1">
                            是</label>
                        <label class="checkbox-inline i-checks"><input name="is_clerk_owner" type="radio"
                                                                       {{$is_has_clerk_owner?'disabled':''}}
                                                                       value="0" checked> 否</label>
                    </div>
                </div>


            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-2">
                    <button class="btn btn-primary" type="submit">保存</button>
                </div>
            </div>
            {!! Form::close() !!}
        </div>

        <div id="spu_modal" class="modal inmodal fade"></div>

    </div>
</div>


{{--@endsection--}}

{{--@section('after-scripts-end')--}}
{!! Html::script(env("APP_URL").'/assets/backend/libs/jquery.zclip/jquery.zclip.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/libs/jquery.form.min.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/libs/datepicker/bootstrap-datetimepicker.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/libs/formvalidation/dist/js/formValidation.min.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/libs/formvalidation/dist/js/framework/bootstrap.min.js') !!}
{!! Html::script(env("APP_URL").'/assets/backend/libs/formvalidation/dist/js/language/zh_CN.js') !!}

{!! Html::script('assets/backend/libs/webuploader-0.1.5/webuploader.js') !!}


<script>
    $(document).ready(function () {
        $('#create-clerk-form').formValidation({
            framework: 'bootstrap',
            icon: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                name: {
                    validators: {
                        notEmpty: {
                            message: '请输入姓名'
                        }
                    }
                },
                /*email: {
                    validators: {
                        regexp: {
                            regexp: /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/,
                            message: '邮箱格式不错误'
                        }
                    }
                },*/
                mobile: {
                    validators: {
                        notEmpty: {
                            message: '请输入手机'
                        },
                        regexp: {
                            regexp: /^1[345678]\d{9}$/,
                            message: '手机号码错误'
                        }
                    }
                },
                clerk_no: {
                    validators: {
                        notEmpty: {
                            message: '请输入导购工号'
                        }
                    }
                },

                password: {
                    validators: {
                        notEmpty: {
                            message: '请输入密码'
                        }
                    }
                },
                password_confirmation: {
                    validators: {
                        identical: {
                            field: 'password',
                            message: '两次输入的密码不一致'
                        }
                    }
                }
            }
        })
    });
</script>
<script>

    // 初始化Web Uploader
    var postImgUrl = '{{route('upload.image',['_token'=>csrf_token()])}}';
    // 初始化Web Uploader
    var uploader = WebUploader.create({
        auto: true,
        swf: '{{url('assets/backend/libs/webuploader-0.1.5/Uploader.swf')}}',
        server: '{{route('upload.image',['_token'=>csrf_token()])}}',
        pick: '#filePicker',
        fileVal: 'upload_image',
        accept: {
            title: 'Images',
            extensions: 'jpg,jpeg,png',
            mimeTypes: 'image/jpg,image/jpeg,image/png'
        }
    });
    // 文件上传成功，给item添加成功class, 用样式标记上传成功。
    uploader.on('uploadSuccess', function (file, response) {
        $('#userAvatar img').attr("src", response.url);
        $('#userAvatar input').val(response.url);
    });

    $('#create-clerk-form').ajaxForm({
        success: function (result) {
            if (!result.status) {
                swal("保存失败!", result.message, "error")
            } else {
                swal({
                    title: "保存成功！",
                    text: "",
                    type: "success"
                }, function () {
                    location = '{{route('admin.shop.clerk.list',['shop_id'=>$shop_id])}}';
                });
            }

        }
    });
</script>
{{--@stop--}}











